<?php
/* 
Plugin Name: Wordpress Sary 
Plugin URI: 
Description: Wordpress Photo Gallery (fully integrated) 
Author: Heriniaina Eugene
Author URI: http://hery.serasera.org
Version: 0.9.0

Copyright 2006 Heriniaina Eugene

Description:
------------


Installation:
-------------


Download:
---------


License:
--------
This program is	free software; you can redistribute it and/or modify it 
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.

This program is	distributed in the hope	that it	will be	useful, but
WITHOUT	ANY WARRANTY; without even the implied warranty	of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
for more details.

You should have	received a copy	of the GNU General Public License along 
with this program; if not, write to the Free Software Foundation, Inc., 59
Temple Place, Suite 330, Boston, MA 02111-1307 USA  


*/

// version 
define('WPSARY_VERSION', '0.9.0');

require_once('wpsary/wpsary-config.php');
require_once('wpsary/wpsary-update.php');
require_once('wpsary/wpsary-admin.php');
require_once('wpsary/wpsary-template.php');

// add actions
add_action('admin_menu', 'wpsary_add_pages');
add_action('init', 'wpsary_init');


// global variables 
global $wpsary_is_gallery_page; // this variable is set to true when we're viewing the gallery page
$wpsary_is_gallery_page = false;

global $wpsary_comments_number; // number of comments on the current lazy-k-gallery file/folder

// v1.4 - use this variable to keep track of whether we have a custom number of comments
global $wpsary_comments_number_set; 
$wpsary_comments_number_set = false;

global $wpsary_subgallery; // v1.3.7 - subdirectory within the gallery folder to display

function wpsary_init() {
	
	$baseurl =  get_option('wpsary_baseurl');

	if ($baseurl && strpos($_SERVER['REQUEST_URI'], "/" . $baseurl) === 0) {
		$_SERVER['WPSARY_REQUEST_URI'] = $_SERVER['REQUEST_URI'];
		$_SERVER['REQUEST_URI'] = $baseurl;
		status_header(200); // ugly, just force a 200 status code
		add_action('template_redirect', 'wpsary_template');
	}

}

function wpsary_add_pages() 
{
	// Add a new menu under Options:	
	//add_management_page('Photo Gallery', 'Photo Gallery', 8, 'edit.php?page=wpsary/wpsary-admin.php');
	//add_submenu_page('edit.php', 'Photo Gallery', 'Photo Gallery', 8, 'edit.php?page=wpsary/wpsary-admin.php');
	add_submenu_page('edit.php', 'Photo Gallery', 'Photo Gallery', 8, 'wpsary', 'wpsary_adminPage');
}


?>
